Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
js join("\n") not start at new line

I am using an Ant Design table, and this is one of my columns. I would like to show every name on a new line, and I'm using "\n" but it's not working - it only adds spaces, it doesn't start the second name at the new line.

{
    title: "Borrower Name",
    width: 150,
    dataIndex: "borrower",
    render: (record) => record.map((a) => a.name).join("\n"),
}
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Another solution is using HTML tag (i have used paragraph tag, you can use br tag), this will display all the names on new line.

{
  title: 'Borrower Name',
  width: 150,
  dataIndex: 'borrower',
  render: (record) => record.map((a) => <p>{a.name}</p>),
},

Or

{
  title: 'Borrower Name',
  width: 150,
  dataIndex: 'borrower',
  render: (record) => record.map((a) => <>{a.name}<br/></>),
},
about 4 years ago · Juan Pablo Isaza Relatório

0

@Help I tried join(<br/>) and join("<br/>"),but both not working;

join(<br/>) will give error join("<br/>") will consider this as separator

(method) Array<string>.join(separator?: string | undefined): string
Adds all the elements of an array into a string, separated by the specified separator string.
@param separator — A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma.

You can map over the record and add a <br/> tag like this:

render: (_: any, row: any) =>['a', 'b'].map((item) => (<>{item}<br /></>))
about 4 years ago · Juan Pablo Isaza Relatório

0

map() function should return something, Should be like this:

render: (record) => record.map(a => {return a.name}).join("\n")

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda